require 'solarpv_tool/tool/solarpv_dialog.rb'

module SolarpvTool
DIR = File.dirname(__FILE__) unless defined?(self::DIR)
  # 工具条
  class ToolManager

    # 初始化
    def initialize
          @solarpv_dialog_tool = SolarpvDialog.new
    end

    # 创建工具条
    def create_toolbar
      solarpv_cmd = create_cmd(@solarpv_dialog_tool,'SolarPV-3D')
      solarpv_cmd.small_icon = File.join(DIR, "images", "icon.png")
      solarpv_cmd.large_icon = File.join(DIR, "images", "icon.png")
      toolbar = UI::Toolbar.new('SolarPV-3D')
      toolbar.add_item(solarpv_cmd)
      toolbar.show
    end

    private

    # 创建激活工具命令
    def create_cmd(tool,name)
      UI::Command.new(name) {
        model = Sketchup.active_model
        model.select_tool(tool)
        tool.show_dialog();
      }
    end
  end
end